package 数学作业.homework1;

import java.util.Random;

public class test3 {

    public static void main(String[] args) {

        DemoTest demoTest = new DemoTest();
        double lambda = 0.1;
        int arr[] = new int[100];
        for (int i = 0; i < 1;){
        int rand = demoTest.rand(lambda);
            if (rand > 0){
                arr[rand] ++;
            }
        }
        for (int i = 1; i < 10;i++){
            System.out.println(arr[i]);
        }
    }

    public static int rand (double lambda) {
        Random random = new Random();
        double u = random.nextDouble();
        int x = 0;
        double cdf = 0;
        while (u >= cdf) {
            x ++;
            cdf = 1 - Math.exp(-1.0 * lambda * x);
        }
        return x;

    }

}
